<template>
  <el-container style="height:100vh">
  <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
    <el-menu router :default-openeds="['2','3']">
      <el-submenu index="1">
        <template slot="title"><i class="el-icon-message"></i>个人中心</template>
        <el-menu-item-group>
          <template slot="title">管理员</template>
          <el-menu-item index="/admins/adminself">个人信息</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title"><i class="el-icon-menu"></i>租赁列表</template>
        <el-menu-item-group>
        <template slot="title">租赁信息</template>
          <el-menu-item index="/admins/lessors">出租方信息</el-menu-item>
          <el-menu-item index="/admins/tenants">租客信息</el-menu-item>
         <el-menu-item index="/admins/parkings">租车位信息</el-menu-item>
          <el-menu-item index="/admins/orders">订单信息</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="3" :disabled="power==2">
        <template slot="title"><i class="el-icon-setting"></i>管理员表单</template>
        <el-menu-item-group>
          <template slot="title">管理员</template>
          <el-menu-item index="/admins/addadmin">新增管理员</el-menu-item>
          <el-menu-item index="/admins/adminlist">管理员列表</el-menu-item>
          <el-menu-item index="/admins/adminlog">管理员日志</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </el-aside>
  
  <el-container>
    <el-header style="text-align: right; font-size: 12px">
      <el-dropdown @command="jumpPage">
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="adminlist">管理员列表</el-dropdown-item>
          <el-dropdown-item command="addadmin">新增管理员</el-dropdown-item>
          <el-dropdown-item command="lessors">出租方列表</el-dropdown-item>
          <el-dropdown-item command="tenants">租方列表</el-dropdown-item>
          <el-dropdown-item command="parkings">租车位列表</el-dropdown-item>
          <el-dropdown-item>订单列表</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <span>王诗语</span>
    </el-header>
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
</template>

<style>
body,html{
  padding:0px;
  margin:0px;
}
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  
  .el-aside {
    color: #333;
  }
</style>

<script>
  export default {
    data() {
      return{
        power:0
      }
    },
    methods:{
      jumpPage(command){
        this.$router.push(`/admins/${command}`)
      },
      async dataInit(){
        const res=await this.$http.post('/admins');
        this.power=res.data.power;
      }
    },
    created(){
      this.dataInit();
    }
  };
</script>